package com.ys.controller.api.sys;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.entity.sys.YsButtonItem;
import com.ys.service.sys.CommonApiService;
import com.ys.service.sys.YsButtonItemService;
import com.ys.vo.LayuiTableVoJA;
import com.ys.vo.R;

@Controller
@RequestMapping("/api/inter/ysButtonItem")
public class ApiInterYsButtonItemController {
	
//	private static final Logger logger = Logger.getLogger(ApiAdminLoginController.class);
	
	@Autowired
	private CommonApiService<YsButtonItem> commonApiService;
	@Autowired
	private YsButtonItemService ysButtonItemService;

//	@RequiresPermissions("system:ysButton:view")
	@RequestMapping("/search")
    @ResponseBody
	public LayuiTableVoJA search(@ModelAttribute YsButtonItem cond){
		
		cond.setOrderby("A.SortNo asc");
		
		return commonApiService.searchLay(cond);
	}
	
	/**
	 * 新增
	 */
	@PostMapping("/add")
    @ResponseBody
	public R add(Long pid,
			Integer sortNo,
			String event,
			String name,
			String icon){
		
		return ysButtonItemService.add(pid, sortNo, event, name, icon);
	}
	
	/*
	 * 彻底删除
	 */
	@PostMapping("/deleteTrue")
	@ResponseBody
	public R deleteTrue(Long id) {
		return ysButtonItemService.deleteTrue(id);
	}
	
}
